#!/bin/bash
SVC=rest
if [ $# -gt 0 ]; then SVC=$1; fi
. ./setEnv.sh
echo "Starting netsar"
/usr/lib/sysstat/sadc -S ALL 10 > "${READINGS_NUMREADINGS}-${SVC}-net.log" &
NETSAR=$!
echo "Starting utilsar"
sar -u 10 > "${READINGS_NUMREADINGS}-${SVC}-util.txt" &
UTILSAR=$!
echo "Starting ${SVC}server"
ant "${SVC}server" &
sleep $((${READINGS_DURATION}/1000+10))
echo "Killing java"
pkill java
echo "Killing netsar (${NETSAR})"
kill $NETSAR
echo "Killing utilsar (${UTILSAR})"
kill $UTILSAR
